<?php
	class commonControl extends control{
		function login(){
			$this->display();
		}
		function userlogin(){
			$db=new mysql("xd_user");
			$username=$_POST['username'];
			$password=$_POST['password'];
			$result=$db->where("username='$username'")->select();
			if(empty($result)){
				echo "<script>alert('用户名不存在！');location.href='".__ROOT__."?c=common&m=login';</script>";
				exit;
			}
			$result=$db->where("username='$username' and password='$password'")->select();
			if(empty($result)){
				echo "<script>alert('密码错误！');location.href='".__ROOT__."?c=common&m=login';</script>";
				exit;
			}
			$sql="select * from xd_user as u inner join xd_role as r inner join xd_user_role as ur on u.uid=ur.uid and r.rid=ur.rid where username='$username'";
			$result=$db->query($sql);
			$_SESSION=$result[0];
			header("location:".__ROOT__."?c=index&m=index");
		}
	}
?>